def gene(s, m):
    n = len(s)
    if m > n or m <= 0:
        return ''

    gc_count = sum(1 for c in s[:m] if c in 'GC')
    gc_count_seq = [gc_count]
    for i in range(1, n - m + 1):
        if s[i-1] in 'GC':
            gc_count -= 1
        if s[i + m - 1] in 'GC':
            gc_count += 1
        gc_count_seq.append(gc_count)

    max_gc_count = max(gc_count_seq)
    index = gc_count_seq.index(max_gc_count)
    return s[index: index + m]


if __name__ == '__main__':
    s = input()
    m = int(input())
    print(gene(s, m))
    